<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>CURLStringFile 类</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="curlfile.setpostfilename.html">« CURLFile::setPostFilename</a></li>
      <li style="float: right;"><a href="curlstringfile.construct.html">CURLStringFile::__construct »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.curl.html">cURL</a></li>
    <li>CURLStringFile 类</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.curlstringfile" class="reference">

 <h1 class="title">CURLStringFile 类</h1>
 

 <div class="partintro"><p class="verinfo">(PHP 8 &gt;= 8.1.0)</p>


  <div class="section" id="curlstringfile.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    <span class="classname"><strong class="classname">CURLStringFile</strong></span> 能够直接把一个变量作为文件上传。
    这与 <span class="classname"><a href="class.curlfile.html" class="classname">CURLFile</a></span> 用法比较相似，但是它使用的是文件的内容，而不是文件名。
    这个类或者 <span class="classname"><a href="class.curlfile.html" class="classname">CURLFile</a></span> 都需要和 <strong><code>CURLOPT_POSTFIELDS</code></strong> 参数一同使用以上传文件。
   </p>
  </div>


  <div class="section" id="curlstringfile.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass">
     
    </div>

    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">CURLStringFile</strong>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 属性 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">public</span>
     <span class="type">string</span>
      <var class="varname"><a href="class.curlstringfile.html#curlstringfile.props.data">$<var class="varname">data</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="type">string</span>
      <var class="varname"><a href="class.curlstringfile.html#curlstringfile.props.postname">$<var class="varname">postname</var></a></var>;</div>

    <div class="fieldsynopsis"><span class="modifier">public</span>
     <span class="type">string</span>
      <var class="varname"><a href="class.curlstringfile.html#curlstringfile.props.mime">$<var class="varname">mime</var></a></var>;</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="curlstringfile.construct.html" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$data</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$postname</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$mime</code><span class="initializer"> = &quot;application/octet-stream&quot;</span></span>)</div>

   }</div>


  </div>
  

  <div class="section" id="curlstringfile.props">
   <h2 class="title">属性</h2>
   <dl>
    
     <dt id="curlstringfile.props.data"><var class="varname">data</var></dt>

     <dd>

      <p class="para">待上传的内容</p>
     </dd>

    
    
     <dt id="curlstringfile.props.postname"><var class="varname">postname</var></dt>

     <dd>

      <p class="para">上传数据中的文件名称</p>
     </dd>

    
    
     <dt id="curlstringfile.props.mime"><var class="varname">mime</var></dt>

     <dd>

      <p class="para">文件的 MIME 类型（默认为 <code class="literal">application/octet-stream</code>）。</p>
     </dd>

    
   </dl>

  </div>


  <div class="section" id="curlstringfile.seealso">
   <h2 class="title">参见</h2>
   <p class="para">
    <ul class="simplelist">
     <li class="member">
      <span class="function"><a href="function.curl-setopt.html" class="function">curl_setopt()</a></span>
     </li>
     <li class="member"><span class="classname"><a href="class.curlfile.html" class="classname">CURLFile</a></span></li>
    </ul>
   </p>
  </div>

 </div>

 








<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="curlstringfile.construct.html">CURLStringFile::__construct</a> — 创建 CURLStringFile 对象</li></ul>
</div>
</div></div></body></html>